<%@ page language="java"
	contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>

	<head>
		<meta charset="utf-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<meta name="viewport" content="width=device-width, initial-scale=1">
		<title>影片</title>
		<script src="../3rd/jquery/jquery-3.4.1.min.js"></script>
		<script type="text/javascript">
			$(
				function() {
					var url = "${pageContext.request.contextPath}/cinema?action=all&time=" + new Date().getTime();;
					var sendData = null;
					$.get(url, sendData, function(backData, textStatus, ajax) {
						var jsonVal = eval("("+ backData +")");
						var num = 0;
						var $div = $("<div class='container' id='movie'></div>");
						for(var i = 0; i < jsonVal.length; i++) {
							var id = jsonVal[i].id;
							var name = jsonVal[i].name;
							var onShelfyear = new Date(jsonVal[i].onShelfDate).getYear()+1900;
							var onShelfMonth = new Date(jsonVal[i].onShelfDate).getMonth()+1;
							var onShelfDay = new Date(jsonVal[i].onShelfDate).getDate();
							var offShelfyear = new Date(jsonVal[i].offShelfDate).getYear()+1900;
							var offShelfMonth = new Date(jsonVal[i].offShelfDate).getMonth()+1;
							var offShelfDay = new Date(jsonVal[i].offShelfDate).getDate();
							var ticketPrice = jsonVal[i].ticketPrice;
							var img = "../upload/" + jsonVal[i].img;
							var url = "${pageContext.request.contextPath}/cinema?action=showSeat&id="+id+"&page=1&ticketPrice="+ticketPrice;
							$div.append("<div class='col-md-3'><div class='panel panel-default'>"
								+"<div class='panel-body'>"
								+"<img src="+ img +" />"
								+"<span>电影名:" + name + "</span><br>"
								+"<span>上架时间:" + onShelfyear + "年" + onShelfMonth + "月" + onShelfDay + "日" + "</span><br>"
								+"<span>下架时间:" + offShelfyear + "年" + offShelfMonth + "月" + offShelfDay + "日" + "</span><br>"
								+"<span>票价:" + ticketPrice + "</span>"
								+"</div>"
								+"<div class='panel-footer'><a href="+ url +">选座购票</a></div>"
								+"</div>");
							num++;
							if(num % 4 == 0){
								$("body").append($div);
								$div = $("<div class='container' id='movie'></div>");
							}
						}
							if(num % 4 != 0)
								$("body").append($div);
					})
				}
			);
		</script>
	</head>
	<body>
		<%@ include file="heard.jsp" %>
	</body>
</html>